// 本文件为title组件相关API

import axios from "@/js/my_axios"

//获取user
function get_case(page, page_size) {
    return axios({
        method: 'get',
        url: 'case_manage/',
        params: {
            'page': page,
            'page_size': page_size,
        },
    }).then((response) => {
        return response
    }).catch((error) => {
        console.log(error);
    });
}

function add_case(params) {
    return axios({
        method: 'post',
        url: 'case_manage/',
        data: params,
    }).then((response) => {
        return response
    }).catch((error) => {
        console.log(error);
    });
}

function modify_case(params) {
    return axios({
        method: 'put',
        url: 'case_manage/',
        data: params,
    }).then((response) => {
        return response
    }).catch((error) => {
        console.log(error);
    });
}

// 删除
function delete_case(val) {
    var status = false
    var val_list = []
    if (Array.isArray(val)) {
        val_list = JSON.parse(JSON.stringify(val))
        status = true
    }
    return axios({
        method: 'delete',
        url: 'case_manage/',
        data: {
            info: status ? val_list : val,
        },
    }).then((response) => {
        return response
    }).catch((error) => {
        console.log(error);
    });
}

export {
    get_case,
    add_case,
    modify_case,
    delete_case,
}